package com.sky.controller.admin;

import com.aliyun.oss.AliyunOSS;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 通用接口
 */
@RestController
@RequestMapping("/admin/common")
@Api(tags = "通用接口")
@Slf4j
public class CommonController {
    @Autowired
    private AliyunOSS aliyunOSS;

    /**
     * 文件上传
     * @return
     */
    @PostMapping("/upload")
    public Result<String> upload(@RequestBody MultipartFile file) throws IOException {
        String url = aliyunOSS.fileLoad(file, "sky-take-out");

        return Result.success(url);
    }
}
